#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int ret;
int n;
int arr[N];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    int i = 0;
    while (i < n)
    {
        if (arr[i] < arr[i + 1])
        {
            while (i + 1 < n && arr[i] <= arr[i + 1]) i++;
            ret++;
        }
        else if (arr[i] > arr[i + 1])
        {
            while (i + 1 < n && arr[i] >= arr[i + 1]) i++;
            ret++;
        }
        else
        {
            while (i + 1 < n && arr[i] == arr[i + 1]) i++;
        }
        i++;
    }
    cout << ret << endl;
    return 0;
}

#include <iostream>
using namespace std;
int t;
int main()
{
    cin >> t;
    while (t--)
    {
        int h = 0, a = 1, ret = 0;
        cin >> h;
        while (h)
        {
            h -= a;
            ret++;
            if (h % (2 * a) == 0)
            {
                a *= 2;
            }
        }
        cout << ret << endl;
    }
    return 0;
}
#include<vector>
class Solution {
public:
    int dp[100100] = { 0 };
    int pos = 0;
    int LIS(vector<int>& a) {
        for (auto& x : a)
        {
            if (pos == 0 || x > dp[pos])
            {
                dp[++pos] = x;
            }
            else
            {
                int l = 1, r = pos;
                while (l < r)
                {
                    int mid = (l + r) / 2;
                    if (dp[mid] >= x) r = mid;
                    else l = mid + 1;
                }
                dp[l] = x;
            }
        }
        return pos;
    }
};